package com.zy.dp.state.example4;

import java.util.Scanner;

public class DepManagerState implements LeaveRequestState
{

	@Override
	public void doWork(StateMachine ctx)
	{

		LeaveRequestModel lrm = (LeaveRequestModel) ctx.getBusinessVO();

		System.out.println("部门经理审核中，请稍候......");

		System.out.println(lrm.getUser() + "申请从" + lrm.getBeginDate() + "开始请假"
				+ lrm.getLeaveDays() + "天,请部门经理审核(1为同意，2为不同意)：");

		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		if (scanner.hasNext())
		{
			int a = scanner.nextInt();
			// 设置回到上下文中
			String result = "不同意";
			if (a == 1)
			{
				result = "同意";
			}
			lrm.setResult("部门经理审核结果：" + result);

			ctx.setState(new AuditOverState());

			ctx.doWork();
		}

	}

}
